package com.come4loves.game.module.skill;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.PostConstruct;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.come4loves.game.module.fight.constants.SkillMoment;
import com.come4loves.game.module.fight.model.FightCard;
import com.come4loves.game.module.fight.model.FightContext;
import com.come4loves.game.module.skill.helper.SkillHelper;

public abstract class AbstractSkillCardParser implements SkillCardParser {
	protected Logger LOGGER = LoggerFactory.getLogger(getClass());
	private static Map<String, AbstractSkillCardParser> map = new HashMap<>();
	@PostConstruct
	private void init(){
		map.put(skillId(), this);
	}
	
	public static AbstractSkillCardParser get(String id) {
		return map.get(id);
	}
	
	protected void cardDamage(FightCard attackerCard, FightCard fightCard, int value, FightContext fightContext){
		if (value > 0)  {
			if (attackerCard.isGenenral()) {//主将造成伤害时
				SkillHelper.handlerSkillModel(attackerCard, SkillMoment.EQUIPGENERALHALTDAMAGE, fightContext.actionRecorder, fightContext.actorBattle, fightContext.allActorBattles, fightContext.chooseTargetsCard);
			}
			if (fightCard.isGenenral()) {//主将受到伤害时
				SkillHelper.handlerSkillModel(fightCard, SkillMoment.EQUIPGENERALDEALDAMAGE, fightContext.actionRecorder, fightContext.actorBattle, fightContext.allActorBattles, fightContext.chooseTargetsCard);
			}
			
		}
	}

}
